/*
 *  $Id: Bury.cs 901 2009-11-28 17:43:43Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Darkness.Abilities {
    public class Bury: AbilityCard<GraveyardData> {
        public Bury(): base("001_d_a_bury") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Darkness;
            Target = GraveyardTarget.Sacrifice;
        }

        protected override void DoAction(TargetArgs<GraveyardData> args) {
            args.Target.MoveToSecondDeck();
            BuryAffect affect = args.Caster.GetAffect<BuryAffect>();
            int value = 1;
            if (affect != null) {
                value += affect.Value;
                args.Caster.RemoveAffect(affect);
            }
            args.Caster.AddAffect(new BuryAffect(value));
        }

        private class BuryAffect: SpellAffect<Bury> {
            public readonly int Value;

            public BuryAffect(int value): base(true) {
                DefaultDescription = true;
                Value = value;
                Add(new Affects.ManaIncome(ElementType.Darkness, value));
            }

            public override string Id {
                get { return AffectManager.GetCardId<Bury>(null); }
            }

            public override bool Dispellable {
                get { return false; }
            }

            public override string DescriptionText {
                get { return Description.GetText(Value); }
            }

            public override Affect Clone() {
                return new BuryAffect(Value);
            }
        }
    }
}
